import axios from '@/utils/request'

// 订单结算确认
export const checkOrder = (mode, obj) => {
  return axios.get('http://smart-shop.itheima.net/index.php?s=/api/checkout/order', {
    params: {
      mode,
      delivery: 10, // 10：快递配送 20：门店自提
      coupinId: 0, // 优惠券ID 传0，表示不适用积分
      isUsePoints: 0, // 积分 传0，不适用积分
      ...obj, // 将传递过来的参数对象 动态展开
      shopId: 0
    }
  })
}

// 提交订单
export const submitOrder = (mode, obj) => {
  return axios.post('http://smart-shop.itheima.net/index.php?s=/api/checkout/submit', {
    mode,
    delivery: 10,
    coupinId: 0,
    isUsePoints: 0,
    payType: 0, // 余额支付
    ...obj
  })
}

// 订单列表
export const getMyOrderList = (dataType, page) => {
  return axios.get('/order/list', {
    params: {
      dataType,
      page // 可以用List进行分页
    }
  })
}
